/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "company_adquired_product")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CompanyAdquiredProduct.findAll", query = "SELECT c FROM CompanyAdquiredProduct c"),
    @NamedQuery(name = "CompanyAdquiredProduct.findByIdCompanyAdquiredProduct", query = "SELECT c FROM CompanyAdquiredProduct c WHERE c.idCompanyAdquiredProduct = :idCompanyAdquiredProduct"),
    @NamedQuery(name = "CompanyAdquiredProduct.findByPrice", query = "SELECT c FROM CompanyAdquiredProduct c WHERE c.price = :price"),
    @NamedQuery(name = "CompanyAdquiredProduct.findByAdquisitionDate", query = "SELECT c FROM CompanyAdquiredProduct c WHERE c.adquisitionDate = :adquisitionDate")})
public class CompanyAdquiredProduct implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_COMPANY_ADQUIRED_PRODUCT")
    private Integer idCompanyAdquiredProduct;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "PRICE")
    private BigDecimal price;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ADQUISITION_DATE")
    @Temporal(TemporalType.DATE)
    private Date adquisitionDate;
    @JoinColumn(name = "COMPANY_PRODUCT", referencedColumnName = "ID_COMPANY_PRODUCT")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private CompanyProduct companyProduct;
    @JoinColumn(name = "COMPANY", referencedColumnName = "ID_COMPANY")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Company company;

    public CompanyAdquiredProduct() {
    }

    public CompanyAdquiredProduct(Integer idCompanyAdquiredProduct) {
        this.idCompanyAdquiredProduct = idCompanyAdquiredProduct;
    }

    public CompanyAdquiredProduct(Integer idCompanyAdquiredProduct, BigDecimal price, Date adquisitionDate) {
        this.idCompanyAdquiredProduct = idCompanyAdquiredProduct;
        this.price = price;
        this.adquisitionDate = adquisitionDate;
    }

    public Integer getIdCompanyAdquiredProduct() {
        return idCompanyAdquiredProduct;
    }

    public void setIdCompanyAdquiredProduct(Integer idCompanyAdquiredProduct) {
        this.idCompanyAdquiredProduct = idCompanyAdquiredProduct;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Date getAdquisitionDate() {
        return adquisitionDate;
    }

    public void setAdquisitionDate(Date adquisitionDate) {
        this.adquisitionDate = adquisitionDate;
    }

    public CompanyProduct getCompanyProduct() {
        return companyProduct;
    }

    public void setCompanyProduct(CompanyProduct companyProduct) {
        this.companyProduct = companyProduct;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCompanyAdquiredProduct != null ? idCompanyAdquiredProduct.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CompanyAdquiredProduct)) {
            return false;
        }
        CompanyAdquiredProduct other = (CompanyAdquiredProduct) object;
        if ((this.idCompanyAdquiredProduct == null && other.idCompanyAdquiredProduct != null) || (this.idCompanyAdquiredProduct != null && !this.idCompanyAdquiredProduct.equals(other.idCompanyAdquiredProduct))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CompanyAdquiredProduct[ idCompanyAdquiredProduct=" + idCompanyAdquiredProduct + " ]";
    }
    
}
